package com.yxw.yxnet_cd_center.customer_service.controller;

import com.yxw.yxnet_cd_center.common.utils.BaseResult;
import com.yxw.yxnet_cd_center.customer_service.entity.YxCsCustTagEntity;
import com.yxw.yxnet_cd_center.customer_service.entity.YxCsTagEntity;
import com.yxw.yxnet_cd_center.customer_service.service.ICustService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 常见问题管理Controller控制层处理
 *
 * @author xiexuxin
 * @date 2023-09-21
 */

@Slf4j
@Api(value = "客户相关", tags = "客户相关")
@RestController
@Validated
@RequestMapping("/v1/cust")
public class CustController {

    @Autowired
    private ICustService custService;

    /**
     * 给客户添加标签
     */
    @ApiOperation("给客户添加标签")
    @PostMapping("/addTag")
    public BaseResult addTag(@RequestBody List<YxCsCustTagEntity> custTags) {
        custService.insertCustTags(custTags);
        return BaseResult.success();
    }

    /**
     * 根据客户ID查询对应标签
     */
    @ApiOperation("根据客户ID查询对应标签")
    @PostMapping("/{custId}/getTagsByCustId")
    public BaseResult getTagsByCustId(@PathVariable Long custId) {
        List<YxCsTagEntity> list = custService.getTagsByCustId(custId);
        return BaseResult.success(list);
    }
}
